import request from "@/api/request.ts";
import type {GetDocPermissionResponse, GrantPermissionRequest} from "@/types";

export const grantPermission = (data: GrantPermissionRequest) : Promise<Boolean> => {
    return request.post(`/docs/permissions`, data)
}

export const getDocPermissionsByUserId = (userId: string, docId: string) : Promise<GetDocPermissionResponse> => {
    return request.get(`/docs/userPermissions/${docId}`, { headers: { 'X-user-Id': userId } })
}

export const removeDocPermission = (userId: string, docId: string) : Promise<Boolean> => {
    return request.delete(`/docs/permissions/${docId}/${userId}`)
}